<?php

namespace application\controller\cp;

use application\controller\cp\BaseController;
use application\service\ImageService;
use application\entity\input\ImageSearch;
use core\system\HttpRequest;

class ImageController extends BaseController {

    private $imageServie;

    public function __construct() {
        parent::__construct();
        $this->imageServie = new ImageService();
        $this->view->layout = '/layout/main';
    }

    /**
     * @module
     * @comment(Danh sách test)
     * @mapping(value=cp/image.html)
     */
    public function grid() {
        $search = HttpRequest::getRequest(ImageSearch::class);
        if (!isset($search->pageIndex) || $search->pageIndex < 0) {
            $search->pageIndex = 1;
        }
        $search->pageSize = 20;
        $this->view->search = $search;
        $dataPage = $this->imageServie->search($search);
        $this->view->dataPage = $dataPage;
        $this->view->scriptClient = 'image.init();';
        $this->view->render('/image/grid');
    }

}
